/*
 * LocationAddress.java
 *
 * Created on January 22, 2007, 2:59 PM
 *
 * Copyright 2008 David D. Emory
 * 
 * This file is part of Five Points. See <http://www.fpdev.org> for
 * additional information regarding the project.
 * 
 * Five Points is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Five Points is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Five Points.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.fpdev.core.basenet;

import org.fpdev.util.FPUtil;

/**
 *
 * @author demory
 */
public class LocationAddress implements Location {

  private String addr_; // resolved address string
  private String city_;
  private BLinkStreet link_; // the street link that contains the address
  private int zip_;

  public LocationAddress(String address, BLinkStreet link, String city, int zip) {
    addr_ = address;
    link_ = link;
    city_ = city;
    zip_ = zip;
  }

  public BNode getNode() {
    return new BNodeAddress(link_, FPUtil.getAddressNumber(addr_));
  }

  public String getDispText(boolean html) {
    String result = addr_;
    if (zip_ > 0) {
      result += ", " + (city_.length() > 0 ? city_ + " " : "") + zip_;
    }
    return result;
  }

  public String getLocText() {
    return "@" + link_.getID() + "@" + FPUtil.getAddressNumber(addr_) + "@" + addr_;
  //return addr_.toLowerCase(); 
  }

  public int getType() {
    return Location.LOC_ADDR;
  }
}
